import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MySlider(),
    );
  }
}

class MySlider extends StatefulWidget {
  @override
  _MySliderState createState() => _MySliderState();
}

class _MySliderState extends State<MySlider> {
  String message = "Slider Scale";
  double val = 2.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: ButtonBar(
        alignment: MainAxisAlignment.start,
        children: <Widget>[
          Slider(
            value: val,
            onChanged: (double e) => changed(e),
            activeColor: Colors.red,
            inactiveColor: Colors.grey,
            divisions: 4,
            // label: "My Slider",
            max: 5.0,
            min: 1.0,
          ),
          Text(message)
        ],
      ),
    );
  }

  changed(e) {
    setState(() {
      val = e;
      // message = "You are set to: ${e.toStringAsFixed(1)}";  
      message = "You are set to: ${e.floor()}";  
    });
  }
}
